package logic

import (
	"context"
	"short-video-dev/videorpc/videorpc"

	"short-video-dev/api/internal/svc"
	"short-video-dev/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PwdForgetLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPwdForgetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PwdForgetLogic {
	return &PwdForgetLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PwdForgetLogic) PwdForget(req *types.PwdForgetRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	data, err := l.svcCtx.VideoRpc.PwdForget(l.ctx, &videorpc.PwdForgetRequest{
		Mobile:      req.Mobile,
		SmsCode:     req.SmsCode,
		Password:    req.Password,
		NewPassword: req.NewPassword,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "密码重置成功",
		Code:    200,
		Data:    data,
	}, nil
}
